package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import java.util.Locale;

import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.SelectStatementContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.StreamNameContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.InsertStatementContext;

/**
 * insert 语句语法遍历
 * 
 * @author zwd
 *
 */
public class InsertStatementVisitor extends AbsCQLParserBaseVisitor<InsertStatementContext> {

	private InsertStatementContext context = null;

	public InsertStatementVisitor() {
		context = new InsertStatementContext();
	}

	@Override
	protected InsertStatementContext defaultResult() {
		return context;
	}

	@Override
	public InsertStatementContext visitStreamName(StreamNameContext ctx) {
		context.setStreamName(ctx.getText().toLowerCase(Locale.US));
		return context;
	}

	@Override
	public InsertStatementContext visitSelectStatement(SelectStatementContext ctx) {
		SelectStatementVisitor visitor = new SelectStatementVisitor();
		context.setSelect(visitor.visit(ctx));
		return context;
	}

}
